<html>
<head>
<title>MusicSever.java</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.s0 { color: #000080; font-weight: bold;}
.s1 { color: #000000;}
.s2 { color: #808080; font-style: italic;}
</style>
</head>
<body bgcolor="#ffffff">
<table CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#c0c0c0" >
<tr><td><center>
<font face="Arial, Helvetica" color="#000000">
MusicSever.java</font>
</center></td></tr></table>
<pre><span class="s0">package </span>com.example.myapplication;

<span class="s0">import </span>android.content.Context;
<span class="s0">import </span>android.media.MediaPlayer;

<span class="s0">public class </span>MusicSever {
<span class="s0">private static </span>MediaPlayer mp = <span class="s0">null</span>;

    <span class="s0">public static void </span>play(Context context, <span class="s0">int </span>resource) {
        stop(context);
        mp = MediaPlayer.create(context, resource);
        mp.setLooping(<span class="s0">true</span>);
        mp.start();
    }

    <span class="s0">public static void </span>stop(Context context) {
        <span class="s2">// TODO Auto-generated method stub</span>
        <span class="s0">if </span>(mp != <span class="s0">null</span>) {
            mp.stop();
            mp.release();
            mp = <span class="s0">null</span>;
        }
    }
}
</pre>
</body>
</html>